home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- # This script installs your books into the Insight bookshelves under SGI_Test.
- # It also copies the helpmaps to the appropriate location.
- # This was created for test purposes only.
- # This script must be run from the directory that the book was built in
- # and you must be logged in as root.
- #
- # TO INSTALL A BOOK
- # If you are installing a book that contains help, it would be a good
- # idea if you did a "versions remove *.books.{BOOKNAME}" before using
- # this script.
- # Syntax: installtestbooks
- #
- # Run "make pub_book" before running this script, if you want
- # anyone to be able to read this book from Insight on your machine.
- #
- # If the current bookshelf does not exist you will get a Warning that looks
- # like the following:
- # Warning: Could not rename /usr/share/Insight/library/SGI_bookshelves/SGI_Test/booklist.txt
- # to /usr/share/Insight/library/SGI_bookshelves/SGI_Test/booklist.txt.O
- # insigtAdmin: No such file or directory
- # This is just a warning and the book should work fine.
- #
- #
- # TO REMOVE A BOOK
- # Use the remove part of this script the same way you would use the install part.
- # This assumes that you have a Makefile with the proper variables and that the
- # variables have not changed since the book was installed.
- # Syntax: installtestbooks rem
- #
- # This was written for the 3.3 book build tools on IRIX 5.3
- # by Derrald Vogt.
- #
- #
- #
- # REVISION HISTORY
- #
- # 3-12-95 Revised script to remove books installed with this
- # script.
- # Fixed a problem which would blow away the bookshelf
- # that the book was being installed on. The original
- # script was picking up spaces in front of the bookname
- # which confused insightAdmin.
- # Also made the script more readable.
- #
- # 1-19-95 Original script written on 1-19-95. This allowed
- # user to install books in work to a Test Bookshelf.
-
-
- # THIS SECTION DEFINES ALL THE VARIABLES
- # -------------------------------------------------------------------
- # -------------------------------------------------------------------
- # Checks to make sure that user is root; if not the script exits.
- echo ""
- if [ `whoami` != root ] ; then
- echo "You must be root to run this script."
- echo ""
- exit
- fi
-
-
- # -------------------------------------------------------------------
- # Defines Title in the Makefile. If the Title is not present the script exits.
- # BOOKNAME=`grep '^TITLE' Makefile | sed 's/^.\{8\}//'`
-
- BOOKNAME=`grep '^TITLE' Makefile | sed 's/^[ ]*TITLE[ ]*=[ ]*\([^ ]*\)$/\1/'`
-
- if [ -z "$BOOKNAME" ] ; then
- echo ""
- echo "No short title was defined for this book."
- echo ""
- exit
- fi
-
-
- # -------------------------------------------------------------------
- # Defines the Bookshelf path. If no path is specified the default is used.
- # This is used to warn the user that the book may already be installed.
-
- SHELF2=`grep '^BOOKSHELF' Makefile | sed 's/^[ ]*BOOKSHELF[ ]*=[ ]*\([^ ]*\)$/\1/'`
-
- if [ -z "$SHELF2" ] ; then
- SHELF2=/usr/share/Insight/library/SGI_bookshelves/SGI_EndUser
- fi
-
-
- # -------------------------------------------------------------------
- # Defines the language of the book. If no langaue is specified in the Makefile
- # the default of C is used.
-
- BOOK=`grep '^BOOK_LANG' Makefile | sed 's/^[ ]*BOOK_LANG[ ]*=[ ]*\([^ ]*\)$/\1/'`
-
- if [ -z "$BOOK" ] ; then
- BOOK=C
- fi
-
-
- # -------------------------------------------------------------------
- # Checks to see what bookshelf the book should be installed on.
- # SHELF1=`grep '^BOOKSHELF' Makefile | sed 's/^.\{12\}//' | cut -f1-6 -d/ `
-
- SHELF1=`grep '^BOOKSHELF' Makefile | sed 's/^[ ]*BOOKSHELF[ ]*=[ ]*\([^ ]*\)$/\1/' | cut -f1-6 -d/ `
-
- if [ -z "$SHELF1" ] ; then
- SHELF=/usr/share/Insight/library/SGI_bookshelves/SGI_Test
- else
- SHELF=$SHELF1/SGI_Test
- fi
-
- # ---------------------------------------------------------------------
- # Checks for the existence of a help directory
-
- if [ -d help ] ; then
- if [ $BOOK = C ] ; then
- HELP=/usr/share/help
- else
- HELP=/usr/share/help/$BOOK
- fi
-
- MAPS=`cd help ; ls *`
- fi
-
-
- # ---------------------------------------------------------------------
- # This prints the name values of the variables defined above.
-
- echo "The current short title of the book is: $BOOKNAME"
- echo "The current book language is: $BOOK"
- echo $BOOKNAME "will be installed in" $SHELF
- echo "The value of SHELF1 is" $SHELF1
- echo "The value of SHELF2 is" $SHELF2
- echo "The value of SHELF is" $SHELF
- echo "The value of HELP is" $HELP
-
-
- # ALL COPY AND REMOVE FUNCTIONS ARE PERFORMED AFTER THIS POINT.
- # --------------------------------------------------------------------
- # --------------------------------------------------------------------
- # Copies the books subdirs and puts them in the Insight Directory.
-
- if [ "$1" != rem ] ; then
-
- if [ -d "$SHELF2/books/$BOOKNAME" ] ; then
- echo ""
- echo $BOOKNAME "already exists on the "$SHELF2" bookshelf."
- echo "You should use \"versions remove\" to remove "$BOOKNAME
- echo "to avoid any potential conflicts."
- echo "Do you want to exit now and do a \"versions remove\" (Y/N)? \c"
- read response
- else
- response=N
- fi
-
- if [ "$response" != N ] ; then
- echo ""
- echo "Exiting script so that a \"versions remove\" can be done on "$BOOKNAME
- echo "Please read the man page on \"versions remove\" for more information."
- echo ""
- exit
- fi
-
- # This is where we copy the helpmap files
- if [ -d help ] ; then
-
- if [ ! -d "$HELP" ] ; then
- mkdir -p $HELP
- fi
-
- cp help/* $HELP/.
- echo "A help directory is present and the contents have been copied to "$HELP
- else
- echo "A help directory is not present."
- fi
-
- if [ -d $SHELF/books/$BOOKNAME ] ; then
- rm -rf $SHELF/books/$BOOKNAME
- fi
-
- mkdir -p $SHELF/books/$BOOKNAME
- cp booklist.txt $SHELF/books/$BOOKNAME/.
- cp -r books/$BOOKNAME/ebt $SHELF/books/$BOOKNAME/.
- cp -r books/$BOOKNAME/figures $SHELF/books/$BOOKNAME/.
- cp -r books/$BOOKNAME/index $SHELF/books/$BOOKNAME/.
- cp -r books/$BOOKNAME/styles $SHELF/books/$BOOKNAME/.
-
- # --------------------------------------------------------------------
- # This runs insightAdmin which adds the book to the bookshelf in Insight
-
- /usr/sbin/insightAdmin -f $SHELF
- echo ""
- echo "Finished copying books to "$SHELF
- echo ""
- fi
-
-
- # --------------------------------------------------------------------
- # --------------------------------------------------------------------
-
- # DERRALD -- ADD CONDITION HERE FOR REMOVING BOOKS
- if [ "$1" = rem ] ; then
-
- # This removes just the book
- echo ""
- echo "WARNING You are about to remove $BOOKNAME from the $SHELF bookshelf"
- echo ""
- echo "This assumes that you have a Makefile with the proper "
- echo "variables and that the variables have not changed"
- echo "since the book was installed with this same script."
- echo ""
- echo "Are you sure you want to do this? (Y/N)? \c"
- read remove
-
- if [ "$remove" = Y ] ; then
- if [ -d $SHELF/books/$BOOKNAME ] ; then
- rm -rf $SHELF/books/$BOOKNAME
- /usr/sbin/insightAdmin -f $SHELF
- echo ""
- echo "Finished removing books from "$SHELF
- echo ""
- fi
- fi
-
- # This removes the helpmaps
- echo "WARNING You are about to remove the following helpmaps"
- echo $MAPS
- echo "from the $HELP directory."
- echo ""
- echo "Are you sure you want to do this? (Y/N)? \c"
- read remhelp
-
- if [ "$remhelp" = Y ] ; then
- cd $HELP ; rm -f $MAPS
- echo "The helmaps have been removed from this book."
- echo ""
- fi
- echo "Finished removing $BOOKNAME"
- echo ""
- fi
-
-